package org.bulldog.playlist.program;

import org.bulldog.playlist.util.DateUtil;

import java.util.Comparator;

/**
 * Created by zhanghongbin on 2017/9/12.
 *
 * @author zhanghongbin
 * @version 1.0
 */
final class ProgramAscendingOrder {

    public final static AscendingOrder ASCENDING_ORDER;

    static {
        ASCENDING_ORDER = new AscendingOrder();
    }

    private ProgramAscendingOrder() {

    }

    private static class AscendingOrder implements Comparator<Program> {

        @Override
        public int compare(Program o1, Program o2) {
            return DateUtil.compare(o1.getStartTime(), o2.getStartTime());
        }
    }

    public static class TimeAscendingOrder implements Comparator<Program> {

        private String currentDate;

        public TimeAscendingOrder() {
            currentDate = DateUtil.now().split(" ")[0] + " ";
        }

        @Override
        public int compare(Program o1, Program o2) {
            return DateUtil.compare(currentDate + " " + o1.getStartTime(), currentDate + " " + o2.getStartTime());
        }
    }
}
